<template>
    <div class="app-container">
        <!-- 表格 -->
        <el-table
        :data="list"
        border
        fit
        highlight-current-row>

        <el-table-column
            label="序号"
            width="70"
            align="center">
            <template slot-scope="scope">
            {{ scope.$index + 1 }}
            </template>
        </el-table-column>
        <el-table-column prop="staffId" label="员工编号" width="200"/>
        <el-table-column prop="assetId" label="资产编号" />
        <el-table-column prop="title" label="资产名称" />
        <el-table-column label="申请状态" >
            <template slot-scope="scope">
            {{ outMap[scope.row.status] }}
            </template>
        </el-table-column>
        <el-table-column prop="des" label="借用原因" />
        <el-table-column label="操作" width="200" align="center">
            <template slot-scope="scope">
                <el-button type="primary" size="mini" icon="el-icon-edit" @click="overAsset(scope.row.id)">通过</el-button>
                <el-button type="danger" size="mini" icon="el-icon-delete" @click="backAsset(scope.row.id)">驳回</el-button>
            </template>
        </el-table-column>
        </el-table>

    </div>
</template>
<script>
//引入 js 文件
import asset from '@/api/manager/asset'
export default {
   // data:{

   // data的两种写法，均可
    data(){return{
            list:null,//查询之后接口返回集合
            outMap:{
              'back':'已经驳回',
              'ed':'已经归还',
              'my':'正在使用',
              'ing':'申请借用中',
              'eding':'申请归还中'}
        }
    },
    created(){this.getList()
    },
    methods:{getList(){ asset.pageAssetStaff()
            .then(response => {
               console.log(response)
                this.list = response.data.rows
            }).catch(error => {
                console.log(error)
            })},
        overAsset(id){
            asset.overAsset(id)
            .then(response => {
                       this.$message({
                        type: 'success',
                        message: '修改成功!'
                    });
                       this.getList()
                    })
        },
        backAsset(id){
            asset.backAsset(id)
               .then(response => {
                       this.$message({
                        type: 'success',
                        message: '修改成功!'
                    });
                       this.getList()
                    })
        }
    }
}
</script>
